package com.fmy.mcsecurity.commons.unusual;

import com.fmy.mcsecurity.commons.resp.SecurityRespEnum;
import org.springframework.security.core.AuthenticationException;

import java.text.MessageFormat;

/**
 * @author Mr.fmy
 * @version 1.0.0
 * @ClassName McSecurityException
 * @Description TODO 统一异常
 * @createTime 2020/4/22 11:42
 */
public class McSecurityException extends AuthenticationException {

    private SecurityRespEnum iEnum;

    public McSecurityException(SecurityRespEnum iEnum) {
        super(iEnum.getDesc());
        this.iEnum = iEnum;
    }

    public McSecurityException(String msg, SecurityRespEnum iEnum) {
        super(MessageFormat.format(iEnum.getDesc(), msg));
        this.iEnum = iEnum;
    }

    public McSecurityException(String msg, Throwable t, SecurityRespEnum iEnum) {
        super(MessageFormat.format(iEnum.getDesc(), msg), t);
        this.iEnum = iEnum;
    }

    public SecurityRespEnum getiEnum() {
        return iEnum;
    }
}
